<?php
/**
 * Created by PhpStorm.
 * User: boye009
 * Date: 2016/3/17
 * Time: 11:02
 */

namespace Test\Controller;

use Common\Api\BoyeServiceApi;

class TestForumThreadController extends TestController{


    public function detail(){

        if(IS_POST){

            $data = array(
                'uid' => I('post.uid',0),
                'tid' => I('post.tid',0),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ForumThread_detail',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function getFavorites(){

        if(IS_POST){

            $data = array(
                'uid' => I('post.uid',0),
                'page_no' => I('post.page_no',1),
                'page_size' => I('post.page_size',10),
                'img_num' => I('post.img_num',3),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ForumThread_getFavorites',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function favorites(){

        if(IS_POST){

            $data = array(
                'tid' => I('post.tid',0),
                'uid' => I('post.uid',0),
                'favorite_value' => I('post.favorite_value',-1),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ForumThread_favorites',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function delete(){

        if(IS_POST){

            $data = array(
                'tid' => I('post.tid',""),
                'uid' => I('post.uid',""),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ForumThread_delete',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();
    }

    public function query(){

        if(IS_POST){

            $data = array(
                'fid' => I('post.fid',0),
                'stick' => I('post.stick',-1),
                'page_no'=> I('post.page_no',1),
                'page_size'=> I('post.page_size',10),
                'name' => I('post.name',''),
                'uid' => I('post.uid',0),
                'img_num' => I('post.img_num',3),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ForumThread_query',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }


    public function add(){

        if(IS_POST){

            $data = array(
                'fid' => I('post.fid',0),
                'typeid' => I('post.typeid',0),
                'author'=> I('post.author',''),
                'author_id'=> I('post.author_id',0),
                'subject'=> I('post.subject',''),
                'message' => I('post.message',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ForumThread_add',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function like(){

        if(IS_POST){

            $data = array(
                'tid' => I('post.tid',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ForumThread_like',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();
    }

    public function digest(){
        if(IS_POST){

            $data = array(
                'tid' => I('post.tid',''),
                'uid' => I('post.uid',''),
                'digest_value' => I('post.digest_value',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ForumThread_digest',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();
    }

    public function stick(){
        if(IS_POST){

            $data = array(
                'tid' => I('post.tid',''),
                'uid' => I('post.uid',''),
                'stick_value' => I('post.stick_value',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ForumThread_stick',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();
    }

    private function parseResult($result){
        echo "解密后数据：";
        dump($result);
    }

}